
function
SlkAction ( scanner )
{              
//  this.scanner = scanner;
    var  semantic_stack = new Stack();
    var  tree = new SlkTree();                  // inheritance
    var  answer = 0;
                    
this.get_answer = function()        { return  answer; }
this.state = function ( number )    { }         // not implemented 
this.predict = function ( production_number )  
{ 
    tree.predict ( production_number );
}
this.reduce = function ( production_number )
{ 
    tree.reduce ( production_number );
}
this.show_tree = function()
{ 
    tree.show_tree();
}
this.show_parse_derivation = function()
{ 
    tree.show_parse_derivation();
}

// -----------------------------------------------------------------------
// grammar action code functions
// -----------------------------------------------------------------------

function
Add ()
{
    var   op;

    answer =  semantic_stack.pop();
    op = semantic_stack.pop();
    if ( op == PLUS_ ) {
        answer = semantic_stack.pop() + answer;
    } else {
        answer = semantic_stack.pop() - answer;
    }
    semantic_stack.push ( answer );
}

function
Finish ()
{
    answer = semantic_stack.pop();
}

function
Multiply ()
{
    var   op;

    answer = semantic_stack.pop();
    op = semantic_stack.pop();
    if ( op == STAR_ ) {
        answer = semantic_stack.pop() * answer;
    } else {
        answer = semantic_stack.pop() / answer;
    }
    semantic_stack.push ( answer );
}

function
Exponent ()
{
    answer = semantic_stack.pop();
    answer = Math.pow ( semantic_stack.pop(), answer );
    semantic_stack.push ( answer );
}

function
Negate ()
{
    answer = semantic_stack.pop();
    semantic_stack.push ( -answer );
}

function
Push ()
{
    semantic_stack.push ( scanner.get_attribute() );
}

// #include SlkExecute.txt

}
